package com.my12306.user.model.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 用户表
 *
 * @Author:苏牧夕
 * @Date:2020-05-15 17:36:13
 * @Version 1.0
 */
@TableName("p_user")
@ApiModel(description = "用户实体")
@Api("用户实体")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PUserEntity implements Serializable, UserDetails {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId
    @ApiModelProperty(name = "id", dataType = "Long", required = false)
    private Long id;
    /**
     * 真实名字
     */
    @ApiModelProperty(dataType = "String", name = "realname", value = "真实姓名", required = true)
    private String realname;
    /**
     * 用户名
     */
    @ApiModelProperty(dataType = "String", name = "username", value = "用户昵称", required = true)
    @NotNull
    private String username;
    /**
     * 密码
     */
    @NotNull
    private String password;
    /**
     * 性别
     */
    @ApiModelProperty(dataType = "Integer", name = "sex", value = "性别", required = false)
    private Integer sex;
    /**
     * 地址
     */
    @ApiModelProperty(dataType = "String", name = "address", value = "地址", required = false)
    private String address;
    /**
     * 邮箱
     */
    @ApiModelProperty(dataType = "String", name = "email", value = "邮箱", required = false)
    private String email;
    /**
     * 电话
     */
    @ApiModelProperty(dataType = "String", name = "phone", value = "用户手机号", required = true)
    @NotNull
    private String phone;
    /**
     * 出身日期
     */
    @ApiModelProperty(dataType = "String", name = "birthday", value = "生日", required = false)
    private String birthday;
    /**
     * 头像地址
     */
    @ApiModelProperty(dataType = "String", name = "imgUrl", value = "头像地址", required = false)
    private String imgUrl;

    /**
     * 用户类型-0-普通用户 1-认证了医生  2-其他专家
     */
    @ApiModelProperty(dataType = "Integer", name = "userType", value = "用户类型-0-普通用户 1-认证了医生  2-其他专家", required = false)
    private Integer userType;
    /**
     * 描述信息
     */
    @ApiModelProperty(dataType = "String", name = "describe", value = "描述信息", required = false)
    private String userDesc;
    /**
     * 显示状态 0-表示禁用 1-表示正常
     */
    @ApiModelProperty(dataType = "Integer", name = "showStatus", value = "显示状态 0-表示禁用 1-表示正常", required = false)
    private Integer showStatus;
    /**
     * 逻辑删除 0-表示删除，1-表示正常
     */
    @ApiModelProperty(dataType = "Integer", name = "logicDelete", value = "逻辑删除 0-表示删除，1-表示正常", required = false)
    private Integer logicDelete;
    /**
     * 注册时间
     */
    @ApiModelProperty(dataType = "Date", name = "logicDelete", value = "注册时间", required = false)
    private Date createDate;
    /**
     * 修改时间
     */
    @ApiModelProperty(dataType = "Date", name = "updateDate", value = "改时间", required = false)
    private Date updateDate;
    /**
     * 身份证
     */
    private String idCard;
    /**
     * 版本号
     */
    @ApiModelProperty(dataType = "Integer", name = "version", value = "本号", required = false)
    private Integer version;
    @ApiModelProperty(dataType = "Integer", name = "recentLogTime", value = "最近登陆时间", required = false)
    private Date recentLogTime;
    /**
     * 验证码的key
     */
    @TableField(exist = false)
    @NotNull
    private String uuid;
    /**
     * 验证码
     */
    @TableField(exist = false)
    @NotNull
    private String captcha;

    @TableField(exist = false)
    private List<GrantedAuthority> Authorities;
    @TableField(exist = false)
    private boolean isAccountNonExpired;
    @TableField(exist = false)
    private boolean isAccountNonLocked;
    @TableField(exist = false)
    private boolean isCredentialsNonExpired;
    @TableField(exist = false)
    private boolean isEnabled;


    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public boolean isAccountNonExpired() {
        return true;
    }

    public void setAccountNonExpired(boolean accountNonExpired) {
        isAccountNonExpired = accountNonExpired;
    }

    public boolean isAccountNonLocked() {
        return true;
    }

    public void setAccountNonLocked(boolean accountNonLocked) {
        isAccountNonLocked = accountNonLocked;
    }

    public boolean isCredentialsNonExpired() {
        return true;
    }

    public void setCredentialsNonExpired(boolean credentialsNonExpired) {
        isCredentialsNonExpired = credentialsNonExpired;
    }

    public boolean isEnabled() {
        return true;
    }

    public void setEnabled(boolean enabled) {
        isEnabled = enabled;
    }

    @Override
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public List<GrantedAuthority> getAuthorities() {
        return Authorities;
    }

    public void setAuthorities(List<GrantedAuthority> authorities) {
        Authorities = authorities;
    }
}
